const logger = require('../utils/logger');
const redisUtil = require('../utils/redisUtil');
const userModule = require('./user')
const kaoqinModule = require('./kaoqin')
const taskModule = require('./task')
const renshiModule = require('./renshi')
const notificationModule = require('./notification')
const xingzhengModule = require('./xingzheng')
const wuziModule = require('./wuzi')
const fawuModule = require('./fawu')
const gongwenModule = require('./gongwen')
const pdfModule = require('./pdf')

// 初始化websocket
function initWs(httpServer) {

    const { Server } = require("socket.io");
    let io = new Server(httpServer, { cors: { origin: "*" }, path: '/socket-io' });

    io.on("connection", async socket => {

        console.log("new connection", socket.handshake.auth)

        // 检测是否传了token
        let token = socket.handshake.auth.token
        if (!token) {
            socket.emit('RE-LOGIN')
            return setTimeout(() => { socket.disconnect(true) }, 1000)
        }

        // 检测token是否合法
        let uid = await redisUtil.get('OA:TOKEN:USER:' + token)
        if (!uid) {
            socket.emit('RE-LOGIN')
            return setTimeout(() => { socket.disconnect(true) }, 1000)
        }

        // 检测登录平台
        let platform = socket.handshake.auth.platform
        console.log('platform', platform)

        // 将之前登录的账号给踢掉
        const socks = await io.in(uid + '-' + platform).fetchSockets()
        for (const s of socks) {
            s.emit('DUPLICATE-LOGIN')
            setTimeout(() => { s.disconnect(true) }, 1000)
        }

        // 加入房间
        let room = uid + '-' + platform
        socket.join(room)
        logger.debug('join room', room)
        socket.uid = uid

        socket.on('disconnect', () => {
            console.log('disconnect', uid, token)
        })

        socket.on('ping', (params, callback) => {
            logger.debug('ping req', socket.uid)
            callback({code: 0, message: 'success', data: 'pong'}) 
        })

        // 获取玩家信息
        socket.on('userInfo', (params, callback) => { userModule.userInfo(io, socket, params, callback) })

        // 修改昵称 
        socket.on('modifyName', (params, callback) => { userModule.modifyName(io, socket, params, callback) })

        // 用户列表
        socket.on('userList', (params, callback) => { userModule.userList(io, socket, params, callback) })

        // 添加用户
        socket.on('addUser', (params, callback) => { userModule.addUser(io, socket, params, callback) })

        // 用户离职
        socket.on('userLizhi', (params, callback) => { userModule.userLizhi(io, socket, params, callback) })

        // 用户转正
        socket.on('userZhuanzheng', (params, callback) => { userModule.userZhuanzheng(io, socket, params, callback) })

        // 修改密码
        socket.on('modifyPwd', (params, callback) => { userModule.modifyPwd(io, socket, params, callback) })

        // 修改用户信息
        socket.on('modifyUserInfo', (params, callback) => { userModule.modifyUserInfo(io, socket, params, callback) })

        socket.on('getUserInfoByUid', (params, callback) => { userModule.getUserInfoByUid(io, socket, params, callback) })

        socket.on('getDpInfoByUid', (params, callback) => { userModule.getDpInfoByUid(io, socket, params, callback) })

        // 联系人列表
        socket.on('contactList', (params, callback) => { userModule.contactList(io, socket, params, callback) })

        // 部门列表
        socket.on('departList', (params, callback) => { userModule.departList(io, socket, params, callback) })
        socket.on('modifyZhijieLingdao', (params, callback) => { userModule.modifyZhijieLingdao(io, socket, params, callback) })
        socket.on('modifyFenguanLingdao', (params, callback) => { userModule.modifyFenguanLingdao(io, socket, params, callback) })
        socket.on('modifyZhuyaoLingdao', (params, callback) => { userModule.modifyZhuyaoLingdao(io, socket, params, callback) })

        // 设置部门领导
        socket.on('setDepartLingdao', (params, callback) => { userModule.setDepartLingdao(io, socket, params, callback) })

        // 查看部门人员
        socket.on('departMembers', (params, callback) => { userModule.departMembers(io, socket, params, callback) })

        // 添加部门
        socket.on('addDepart', (params, callback) => { userModule.addDepart(io, socket, params, callback) })

        // 删除部门
        socket.on('delDepart', (params, callback) => { userModule.delDepart(io, socket, params, callback) })

        // 岗位列表
        socket.on('posList', (params, callback) => { userModule.posList(io, socket, params, callback) })
        // 查看岗位人员
        socket.on('posMembers', (params, callback) => { userModule.posMembers(io, socket, params, callback) })
        // 添加岗位
        socket.on('addPos', (params, callback) => { userModule.addPos(io, socket, params, callback) })
        socket.on('modifyPosName', (params, callback) => { userModule.modifyPosName(io, socket, params, callback) })
        // 删除岗位
        socket.on('delPos', (params, callback) => { userModule.delPos(io, socket, params, callback) })

        // 岗位列表
        socket.on('roleList', (params, callback) => { userModule.roleList(io, socket, params, callback) })
        // 查看岗位人员
        socket.on('roleMembers', (params, callback) => { userModule.roleMembers(io, socket, params, callback) })
        // 添加岗位
        socket.on('addRole', (params, callback) => { userModule.addRole(io, socket, params, callback) })
        socket.on('modifyRoleName', (params, callback) => { userModule.modifyRoleName(io, socket, params, callback) })
        // 删除岗位
        socket.on('delRole', (params, callback) => { userModule.delRole(io, socket, params, callback) })

        // 节假日配置
        socket.on('getJiejieriConfig', (params, callback) => { userModule.getJiejieriConfig(io, socket, params, callback) })
        socket.on('updateJiejiariConfig', (params, callback) => { userModule.updateJiejiariConfig(io, socket, params, callback) })

        // 排班
        socket.on('getXiuxiDayList', (params, callback) => { userModule.getXiuxiDayList(io, socket, params, callback) })
        socket.on('getXiuxiDayListApp', (params, callback) => { userModule.getXiuxiDayListApp(io, socket, params, callback) })
        socket.on('addPaiban', (params, callback) => { userModule.addPaiban(io, socket, params, callback) })
        socket.on('paibanDetail', (params, callback) => { userModule.paibanDetail(io, socket, params, callback) })
        socket.on('paibanStatis', (params, callback) => { userModule.paibanStatis(io, socket, params, callback) })
        socket.on('paibanMonthDetail', (params, callback) => { userModule.paibanMonthDetail(io, socket, params, callback) })

        // 获取日程
        socket.on('getSchedule', (params, callback) => { userModule.getSchedule(io, socket, params, callback) })

        // 今日打卡详情
        socket.on('todayDakaDetail', (params, callback) => { kaoqinModule.todayDakaDetail(io, socket, params, callback) })

        // 打卡
        socket.on('daka', (params, callback) => { kaoqinModule.daka(io, socket, params, callback) })
        socket.on('dakaList', (params, callback) => { kaoqinModule.dakaList(io, socket, params, callback) })

        // 补卡
        socket.on('bukaApply', (params, callback) => { kaoqinModule.bukaApply(io, socket, params, callback) })
        socket.on('revertBukaApply', (params, callback) => { kaoqinModule.revertBukaApply(io, socket, params, callback) })
        socket.on('bukaApplyRecord', (params, callback) => { kaoqinModule.bukaApplyRecord(io, socket, params, callback) })
        socket.on('bukaApplyDetail', (params, callback) => { kaoqinModule.bukaApplyDetail(io, socket, params, callback) })

        // 个人考勤统计
        socket.on('personalKaoqinStatis', (params, callback) => { kaoqinModule.personalKaoqinStatis(io, socket, params, callback) })

        // 部门考勤统计
        socket.on('groupKaoqinStatis', (params, callback) => { kaoqinModule.groupKaoqinStatis(io, socket, params, callback) })
        socket.on('exportGroupStatis', (params, callback) => { kaoqinModule.exportGroupStatis(io, socket, params, callback) })

        // 获取考勤设置
        socket.on('getKaoqinSetting', (params, callback) => { kaoqinModule.getKaoqinSetting(io, socket, params, callback) })

        // 更新考勤设置
        socket.on('updateKaoqinSetting', (params, callback) => { kaoqinModule.updateKaoqinSetting(io, socket, params, callback) })

        // 请假申请
        socket.on('vacationApply', (params, callback) => { kaoqinModule.vacationApply(io, socket, params, callback) })
        socket.on('revertVacationApply', (params, callback) => { kaoqinModule.revertVacationApply(io, socket, params, callback) })
        socket.on('xiaojia', (params, callback) => { kaoqinModule.xiaojia(io, socket, params, callback) })
        socket.on('vacationApplyRecord', (params, callback) => { kaoqinModule.vacationApplyRecord(io, socket, params, callback) })
        socket.on('vacationApplyRecordWeb', (params, callback) => { kaoqinModule.vacationApplyRecordWeb(io, socket, params, callback) })
        socket.on('vacationApplyDetail', (params, callback) => { kaoqinModule.vacationApplyDetail(io, socket, params, callback) })

        // 出差申请
        socket.on('chuchaiApply', (params, callback) => { kaoqinModule.chuchaiApply(io, socket, params, callback) })
        socket.on('revertChuchaiApply', (params, callback) => { kaoqinModule.revertChuchaiApply(io, socket, params, callback) })
        socket.on('chuchaiApplyRecord', (params, callback) => { kaoqinModule.chuchaiApplyRecord(io, socket, params, callback) })
        socket.on('chuchaiApplyRecordWeb', (params, callback) => { kaoqinModule.chuchaiApplyRecordWeb(io, socket, params, callback) })
        socket.on('chuchaiApplyDetail', (params, callback) => { kaoqinModule.chuchaiApplyDetail(io, socket, params, callback) })

        // 加班申请
        socket.on('jiabanApply', (params, callback) => { kaoqinModule.jiabanApply(io, socket, params, callback) })
        socket.on('revertJiabanApply', (params, callback) => { kaoqinModule.revertJiabanApply(io, socket, params, callback) })
        socket.on('jiabanApplyRecord', (params, callback) => { kaoqinModule.jiabanApplyRecord(io, socket, params, callback) })
        socket.on('jiabanApplyRecordWeb', (params, callback) => { kaoqinModule.jiabanApplyRecordWeb(io, socket, params, callback) })
        socket.on('jiabanApplyDetail', (params, callback) => { kaoqinModule.jiabanApplyDetail(io, socket, params, callback) })

        socket.on('getUserDakaSetting', (params, callback) => { kaoqinModule.getUserDakaSetting(io, socket, params, callback) })
        socket.on('updateUserDakaSetting', (params, callback) => { kaoqinModule.updateUserDakaSetting(io, socket, params, callback) })

        // 获取未完成任务数量
        socket.on('getUnfinishedTaskCnt', (params, callback) => { taskModule.getUnfinishedTaskCnt(io, socket, params, callback) })

        // 获取任务列表 
        socket.on('getTaskList', (params, callback) => { taskModule.getTaskList(io, socket, params, callback) })
        socket.on('getTaskDetail', (params, callback) => { taskModule.getTaskDetail(io, socket, params, callback) })
        socket.on('getTaskListWeb', (params, callback) => { taskModule.getTaskListWeb(io, socket, params, callback) })
        socket.on('getTaskListYiwancheng', (params, callback) => { taskModule.getTaskListYiwancheng(io, socket, params, callback) })
        socket.on('getTaskListWeiwancheng', (params, callback) => { taskModule.getTaskListWeiwancheng(io, socket, params, callback) })
        socket.on('getTaskListWithStatusWeb', (params, callback) => { taskModule.getTaskListWithStatusWeb(io, socket, params, callback) })

        // 同意任务
        socket.on('agreeTask', (params, callback) => { taskModule.agreeTask(io, socket, params, callback) })

        // 拒绝任务
        socket.on('rejectTask', (params, callback) => { taskModule.rejectTask(io, socket, params, callback) })

        // 确认任务执行
        socket.on('confirmTask', (params, callback) => { taskModule.confirmTask(io, socket, params, callback) })
        socket.on('confirmTaskTongzhi', (params, callback) => { taskModule.confirmTaskTongzhi(io, socket, params, callback) })

        // 获取未读通知数量
        socket.on('getUnreadNotificationCnt', (params, callback) => { notificationModule.getUnreadNotificationCnt(io, socket, params, callback) })
        // 获取通知消息列表
        socket.on('getNotificationList', (params, callback) => { notificationModule.getNotificationList(io, socket, params, callback) })
        socket.on('getNotificationListWeb', (params, callback) => { notificationModule.getNotificationListWeb(io, socket, params, callback) })
        socket.on('getNotificationListWithStatusWeb', (params, callback) => { notificationModule.getNotificationListWithStatusWeb(io, socket, params, callback) })

        // 获取通知消息详情
        socket.on('getNotificationInfo', (params, callback) => { notificationModule.getNotificationInfo(io, socket, params, callback) })

        // 阅读通知
        socket.on('readNotification', (params, callback) => { notificationModule.readNotification(io, socket, params, callback) })

        // 入职申请
        socket.on('entryApply', (params, callback) => { renshiModule.entryApply(io, socket, params, callback) })
        socket.on('revertEntryApply', (params, callback) => { renshiModule.revertEntryApply(io, socket, params, callback) })
        socket.on('entryApplyRecord', (params, callback) => { renshiModule.entryApplyRecord(io, socket, params, callback) })
        socket.on('entryApplyRecordWeb', (params, callback) => { renshiModule.entryApplyRecordWeb(io, socket, params, callback) })
        socket.on('entryApplyDetail', (params, callback) => { renshiModule.entryApplyDetail(io, socket, params, callback) })

        // 转正申请
        socket.on('zhuanzhengApply', (params, callback) => { renshiModule.zhuanzhengApply(io, socket, params, callback) })
        socket.on('revertZhuanzhengApply', (params, callback) => { renshiModule.revertZhuanzhengApply(io, socket, params, callback) })
        socket.on('zhuanzhengApplyRecord', (params, callback) => { renshiModule.zhuanzhengApplyRecord(io, socket, params, callback) })
        socket.on('zhuanzhengApplyRecordWeb', (params, callback) => { renshiModule.zhuanzhengApplyRecordWeb(io, socket, params, callback) })
        socket.on('zhuanzhengApplyDetail', (params, callback) => { renshiModule.zhuanzhengApplyDetail(io, socket, params, callback) })

        // 离职申请
        socket.on('departureApply', (params, callback) => { renshiModule.departureApply(io, socket, params, callback) })
        socket.on('revertDepartureApply', (params, callback) => { renshiModule.revertDepartureApply(io, socket, params, callback) })
        socket.on('departureApplyRecord', (params, callback) => { renshiModule.departureApplyRecord(io, socket, params, callback) })
        socket.on('departureApplyRecordWeb', (params, callback) => { renshiModule.departureApplyRecordWeb(io, socket, params, callback) })
        socket.on('departureApplyDetail', (params, callback) => { renshiModule.departureApplyDetail(io, socket, params, callback) })

        // 工资单
        socket.on('gongziRecord', (params, callback) => { renshiModule.gongziRecord(io, socket, params, callback) })
        socket.on('gongziRecordWeb', (params, callback) => { renshiModule.gongziRecordWeb(io, socket, params, callback) })
        // 工资模板下载地址
        socket.on('gongziTemplateDownloadUrl', (params, callback) => { renshiModule.gongziTemplateDownloadUrl(io, socket, params, callback) })
        // 工资上传
        socket.on('newGongziUpload', (params, callback) => { renshiModule.newGongziUpload(io, socket, params, callback) })
        socket.on('gongziUploadRecord', (params, callback) => { renshiModule.gongziUploadRecord(io, socket, params, callback) })

        // 督办单申请
        socket.on('dubandanApply', (params, callback) => { xingzhengModule.dubandanApply(io, socket, params, callback) })
        socket.on('revertDubandanApply', (params, callback) => { xingzhengModule.revertDubandanApply(io, socket, params, callback) })
        socket.on('dubandanApplyRecord', (params, callback) => { xingzhengModule.dubandanApplyRecord(io, socket, params, callback) })
        socket.on('dubandanApplyRecordWeb', (params, callback) => { xingzhengModule.dubandanApplyRecordWeb(io, socket, params, callback) })
        socket.on('dubandanApplyDetail', (params, callback) => { xingzhengModule.dubandanApplyDetail(io, socket, params, callback) })

        // 会议室申请
        socket.on('meetingRoomApply', (params, callback) => { xingzhengModule.meetingRoomApply(io, socket, params, callback) })
        socket.on('revertMeetingRoomApply', (params, callback) => { xingzhengModule.revertMeetingRoomApply(io, socket, params, callback) })
        socket.on('meetingRoomApplyRecord', (params, callback) => { xingzhengModule.meetingRoomApplyRecord(io, socket, params, callback) })
        socket.on('meetingRoomApplyRecordWeb', (params, callback) => { xingzhengModule.meetingRoomApplyRecordWeb(io, socket, params, callback) })
        socket.on('meetingRoomApplyDetail', (params, callback) => { xingzhengModule.meetingRoomApplyDetail(io, socket, params, callback) })

        // 接待单申请
        socket.on('jiedaiApply', (params, callback) => { xingzhengModule.jiedaiApply(io, socket, params, callback) })
        socket.on('revertJiedaiApply', (params, callback) => { xingzhengModule.revertJiedaiApply(io, socket, params, callback) })
        socket.on('jiedaiApplyRecord', (params, callback) => { xingzhengModule.jiedaiApplyRecord(io, socket, params, callback) })
        socket.on('jiedaiApplyRecordWeb', (params, callback) => { xingzhengModule.jiedaiApplyRecordWeb(io, socket, params, callback) })
        socket.on('jiedaiApplyDetail', (params, callback) => { xingzhengModule.jiedaiApplyDetail(io, socket, params, callback) })

        // 加油申请
        socket.on('jiayouApply', (params, callback) => { xingzhengModule.jiayouApply(io, socket, params, callback) })
        socket.on('revertJiayouApply', (params, callback) => { xingzhengModule.revertJiayouApply(io, socket, params, callback) })
        socket.on('jiayouApplyRecord', (params, callback) => { xingzhengModule.jiayouApplyRecord(io, socket, params, callback) })
        socket.on('jiayouApplyRecordWeb', (params, callback) => { xingzhengModule.jiayouApplyRecordWeb(io, socket, params, callback) })
        socket.on('jiayouApplyDetail', (params, callback) => { xingzhengModule.jiayouApplyDetail(io, socket, params, callback) })

        // 用车申请
        socket.on('yongcheApply', (params, callback) => { xingzhengModule.yongcheApply(io, socket, params, callback) })
        socket.on('revertYongcheApply', (params, callback) => { xingzhengModule.revertYongcheApply(io, socket, params, callback) })
        socket.on('yongcheApplyRecord', (params, callback) => { xingzhengModule.yongcheApplyRecord(io, socket, params, callback) })
        socket.on('yongcheApplyRecordWeb', (params, callback) => { xingzhengModule.yongcheApplyRecordWeb(io, socket, params, callback) })
        socket.on('yongcheApplyDetail', (params, callback) => { xingzhengModule.yongcheApplyDetail(io, socket, params, callback) })

        // 用印申请
        socket.on('yongyinApply', (params, callback) => { xingzhengModule.yongyinApply(io, socket, params, callback) })
        socket.on('revertYongyinApply', (params, callback) => { xingzhengModule.revertYongyinApply(io, socket, params, callback) })
        socket.on('yongyinApplyRecord', (params, callback) => { xingzhengModule.yongyinApplyRecord(io, socket, params, callback) })
        socket.on('yongyinApplyRecordWeb', (params, callback) => { xingzhengModule.yongyinApplyRecordWeb(io, socket, params, callback) })
        socket.on('yongyinApplyDetail', (params, callback) => { xingzhengModule.yongyinApplyDetail(io, socket, params, callback) })

        // 排班
        socket.on('getPaibanSetting', (params, callback) => { xingzhengModule.getPaibanSetting(io, socket, params, callback) })
        socket.on('updatePaibanSetting', (params, callback) => { xingzhengModule.updatePaibanSetting(io, socket, params, callback) })
        socket.on('autoPaiban', (params, callback) => { xingzhengModule.autoPaiban(io, socket, params, callback) })

        // 发起会议
        socket.on('newHuiyiTongzhi', (params, callback) => { notificationModule.newHuiyiTongzhi(io, socket, params, callback) })
        socket.on('huiyiTongzhiRecord', (params, callback) => { notificationModule.huiyiTongzhiRecord(io, socket, params, callback) })
        socket.on('huiyiTongzhiRecordWeb', (params, callback) => { notificationModule.huiyiTongzhiRecordWeb(io, socket, params, callback) })
        socket.on('huiyiTongzhiDetail', (params, callback) => { notificationModule.huiyiTongzhiDetail(io, socket, params, callback) })

        // 工作通知
        socket.on('newGongzuoTongzhi', (params, callback) => { notificationModule.newGongzuoTongzhi(io, socket, params, callback) })
        socket.on('gongzuoTongzhiRecord', (params, callback) => { notificationModule.gongzuoTongzhiRecord(io, socket, params, callback) })
        socket.on('gongzuoTongzhiRecordWeb', (params, callback) => { notificationModule.gongzuoTongzhiRecordWeb(io, socket, params, callback) })
        socket.on('gongzuoTongzhiDetail', (params, callback) => { notificationModule.gongzuoTongzhiDetail(io, socket, params, callback) })

        // 采购申请
        socket.on('caigouApply', (params, callback) => { wuziModule.caigouApply(io, socket, params, callback) })
        socket.on('revertCaigouApply', (params, callback) => { wuziModule.revertCaigouApply(io, socket, params, callback) })
        socket.on('caigouApplyRecord', (params, callback) => { wuziModule.caigouApplyRecord(io, socket, params, callback) })
        socket.on('caigouApplyRecordWeb', (params, callback) => { wuziModule.caigouApplyRecordWeb(io, socket, params, callback) })
        socket.on('caigouApplyDetail', (params, callback) => { wuziModule.caigouApplyDetail(io, socket, params, callback) })

        // 物资领用申请
        socket.on('wuzilingyong', (params, callback) => { wuziModule.wuzilingyong(io, socket, params, callback) })
        socket.on('revertWuzilingyong', (params, callback) => { wuziModule.revertWuzilingyong(io, socket, params, callback) })
        socket.on('wuzilingyongRecord', (params, callback) => { wuziModule.wuzilingyongRecord(io, socket, params, callback) })
        socket.on('wuzilingyongRecordWeb', (params, callback) => { wuziModule.wuzilingyongRecordWeb(io, socket, params, callback) })
        socket.on('wuzilingyongDetail', (params, callback) => { wuziModule.wuzilingyongDetail(io, socket, params, callback) })

        // 合同审批
        socket.on('hetongShenpi', (params, callback) => { fawuModule.hetongShenpi(io, socket, params, callback) })
        socket.on('revertHetongShenpi', (params, callback) => { fawuModule.revertHetongShenpi(io, socket, params, callback) })
        socket.on('hetongShenpiRecord', (params, callback) => { fawuModule.hetongShenpiRecord(io, socket, params, callback) })
        socket.on('hetongShenpiRecordWeb', (params, callback) => { fawuModule.hetongShenpiRecordWeb(io, socket, params, callback) })
        socket.on('hetongShenpiDetail', (params, callback) => { fawuModule.hetongShenpiDetail(io, socket, params, callback) })

        // 招标审核
        socket.on('zhaobiaoShenhe', (params, callback) => { fawuModule.zhaobiaoShenhe(io, socket, params, callback) })
        socket.on('revertZhaobiaoShenhe', (params, callback) => { fawuModule.revertZhaobiaoShenhe(io, socket, params, callback) })
        socket.on('zhaobiaoShenheRecord', (params, callback) => { fawuModule.zhaobiaoShenheRecord(io, socket, params, callback) })
        socket.on('zhaobiaoShenheRecordWeb', (params, callback) => { fawuModule.zhaobiaoShenheRecordWeb(io, socket, params, callback) })
        socket.on('zhaobiaoShenheDetail', (params, callback) => { fawuModule.zhaobiaoShenheDetail(io, socket, params, callback) })

        // 传阅文件
        socket.on('chuanyueWenjian', (params, callback) => { gongwenModule.chuanyueWenjian(io, socket, params, callback) })
        socket.on('revertChuanyueWenjian', (params, callback) => { gongwenModule.revertChuanyueWenjian(io, socket, params, callback) })
        socket.on('chuanyueWenjianRecord', (params, callback) => { gongwenModule.chuanyueWenjianRecord(io, socket, params, callback) })
        socket.on('chuanyueWenjianRecordWeb', (params, callback) => { gongwenModule.chuanyueWenjianRecordWeb(io, socket, params, callback) })
        socket.on('chuanyueWenjianDetail', (params, callback) => { gongwenModule.chuanyueWenjianDetail(io, socket, params, callback) })

        // 公文流转
        socket.on('gongwenLiuzhuan', (params, callback) => { gongwenModule.gongwenLiuzhuan(io, socket, params, callback) })
        socket.on('revertGongwenLiuzhuan', (params, callback) => { gongwenModule.revertGongwenLiuzhuan(io, socket, params, callback) })
        socket.on('finishGongwenLiuzhuan', (params, callback) => { gongwenModule.finishGongwenLiuzhuan(io, socket, params, callback) })
        socket.on('gongwenLiuzhuanRecord', (params, callback) => { gongwenModule.gongwenLiuzhuanRecord(io, socket, params, callback) })
        socket.on('gongwenLiuzhuanRecordWeb', (params, callback) => { gongwenModule.gongwenLiuzhuanRecordWeb(io, socket, params, callback) })
        socket.on('gongwenLiuzhuanDetail', (params, callback) => { gongwenModule.gongwenLiuzhuanDetail(io, socket, params, callback) })
        socket.on('gongwenliuzhuanYueban', (params, callback) => { gongwenModule.gongwenliuzhuanYueban(io, socket, params, callback) })

        // 内部发文
        socket.on('neibuFawen', (params, callback) => { gongwenModule.neibuFawen(io, socket, params, callback) })
        socket.on('revertNeibuFawen', (params, callback) => { gongwenModule.revertNeibuFawen(io, socket, params, callback) })
        socket.on('neibuFawenRecord', (params, callback) => { gongwenModule.neibuFawenRecord(io, socket, params, callback) })
        socket.on('neibuFawenRecordWeb', (params, callback) => { gongwenModule.neibuFawenRecordWeb(io, socket, params, callback) })
        socket.on('neibuFawenDetail', (params, callback) => { gongwenModule.neibuFawenDetail(io, socket, params, callback) })

        // 获取公文信息
        socket.on('getGongwenInfo', (params, callback) => { gongwenModule.getGongwenInfo(io, socket, params, callback) })

        // 收藏公文
        socket.on('shoucangGongwen', (params, callback) => { gongwenModule.shoucangGongwen(io, socket, params, callback) })
        socket.on('cancelShoucang', (params, callback) => { gongwenModule.cancelShoucang(io, socket, params, callback) })

        // 获取公文历史列表
        socket.on('getGongwenHistoryList', (params, callback) => { gongwenModule.getGongwenHistoryList(io, socket, params, callback) })
        socket.on('getGongwenHistoryListType', (params, callback) => { gongwenModule.getGongwenHistoryListType(io, socket, params, callback) })
        socket.on('getGongwenHistoryListWeb', (params, callback) => { gongwenModule.getGongwenHistoryListWeb(io, socket, params, callback) })

        // 获取公文收藏列表
        socket.on('getGongwenShoucangList', (params, callback) => { gongwenModule.getGongwenShoucangList(io, socket, params, callback) })
        socket.on('gongwenShoucangListWeb', (params, callback) => { gongwenModule.gongwenShoucangListWeb(io, socket, params, callback) })

        // 文件标签
        socket.on('fileTagList', (params, callback) => { gongwenModule.fileTagList(io, socket, params, callback) })
        socket.on('fileTagAdd', (params, callback) => { gongwenModule.fileTagAdd(io, socket, params, callback) })
        socket.on('fileTagModify', (params, callback) => { gongwenModule.fileTagModify(io, socket, params, callback) })

        // 车牌
        socket.on('chepaiList', (params, callback) => { userModule.chepaiList(io, socket, params, callback) })
        socket.on('deleteChepai', (params, callback) => { userModule.deleteChepai(io, socket, params, callback) })
        socket.on('addChepai', (params, callback) => { userModule.addChepai(io, socket, params, callback) })

        // 印章
        socket.on('yinzhangList', (params, callback) => { userModule.yinzhangList(io, socket, params, callback) })
        socket.on('deleteYinzhang', (params, callback) => { userModule.deleteYinzhang(io, socket, params, callback) })
        socket.on('addYinzhang', (params, callback) => { userModule.addYinzhang(io, socket, params, callback) })

        // 会议室
        socket.on('huiyishiList', (params, callback) => { userModule.huiyishiList(io, socket, params, callback) })
        socket.on('deleteHuiyishi', (params, callback) => { userModule.deleteHuiyishi(io, socket, params, callback) })
        socket.on('addHuiyishi', (params, callback) => { userModule.addHuiyishi(io, socket, params, callback) })

        // 请假
        socket.on('qingjiaList', (params, callback) => { userModule.qingjiaList(io, socket, params, callback) })
        socket.on('deleteQingjia', (params, callback) => { userModule.deleteQingjia(io, socket, params, callback) })
        socket.on('addQingjia', (params, callback) => { userModule.addQingjia(io, socket, params, callback) })

        socket.on('getEventConfig', (params, callback) => { userModule.getEventConfig(io, socket, params, callback) })
        socket.on('getRootConfig', (params, callback) => { userModule.getRootConfig(io, socket, params, callback) })

        socket.on('getAuditors', (params, callback) => { userModule.getAuditors(io, socket, params, callback) })

        socket.on('getLingdao', (params, callback) => { userModule.getLingdao(io, socket, params, callback) })

        socket.on('getDepartmentLingdao', (params, callback) => { userModule.getDepartmentLingdao(io, socket, params, callback) })

        socket.on('modifyDepartment', (params, callback) => { userModule.modifyDepartment(io, socket, params, callback) })

        socket.on('saveAuditStep', (params, callback) => { userModule.saveAuditStep(io, socket, params, callback) })
        socket.on('saveChengbanStep', (params, callback) => { userModule.saveChengbanStep(io, socket, params, callback) })

        socket.on('getAllUsers', (params, callback) => { userModule.getAllUsers(io, socket, params, callback) })
        socket.on('getUserPermissionsApp', (params, callback) => { userModule.getUserPermissionsApp(io, socket, params, callback) })
        socket.on('getUserPermissionsWeb', (params, callback) => { userModule.getUserPermissionsWeb(io, socket, params, callback) })

        socket.on('getPermissionsUsers', (params, callback) => { userModule.getPermissionsUsers(io, socket, params, callback) })
        socket.on('setPermissionUsers', (params, callback) => { userModule.setPermissionUsers(io, socket, params, callback) })

        socket.on('getUserGroupList', (params, callback) => { userModule.getUserGroupList(io, socket, params, callback) })
        socket.on('addUserGroup', (params, callback) => { userModule.addUserGroup(io, socket, params, callback) })
        socket.on('delUserGroup', (params, callback) => { userModule.delUserGroup(io, socket, params, callback) })
        socket.on('modifyUserGroup', (params, callback) => { userModule.modifyUserGroup(io, socket, params, callback) })

        // 获取时间段内上班详情
        socket.on('getShangbanDetail', (params, callback) => { userModule.getShangbanDetail(io, socket, params, callback) })

        // 催办
        socket.on('cuiban', (params, callback) => { userModule.cuiban(io, socket, params, callback) })

        socket.on('printPdf', (params, callback) => { pdfModule.printPdf(io, socket, params, callback) })
    });

    let redisClient = redisUtil.newClient()
    redisClient.subscribe('REFRESH_CONTACT', () => {})
    redisClient.on('message', (channel, msg) => {
        logger.debug('redis channel', channel, msg)
        if (channel == 'REFRESH_CONTACT') {
            io.emit('REFRESH_CONTACT')
        }
    })
}

module.exports = {
    initWs
}
